package org.linlinjava.litemall.admin.service2;

import org.linlinjava.litemall.db.dao.*;
import org.linlinjava.litemall.db.domain.*;
import org.springframework.beans.factory.annotation.Autowired;

import javax.persistence.EntityManager;
import javax.persistence.Query;

public class ABaseService {

    protected TUserInfo findUserInfoByUser2Id(Integer userId) {
        return userInfoMapper.selectOneByExample(TUserInfoExample.newAndCreateCriteria().andUser2IdEqualTo(userId).example());
    }

    protected TUser2 findUserByCode(String code) {
        return user2Mapper.selectOneByExample(TUser2Example.newAndCreateCriteria().andCodeEqualTo(code).example());
    }

    protected TUser2 findUserById(Integer id) {
        return user2Mapper.selectByPrimaryKey(id);
    }

    protected TShop findShopByUser2Id(Integer userId) {
        return shopMapper.selectOneByExample(TShopExample.newAndCreateCriteria().andUser2IdEqualTo(userId).example());
    }


    public TGoods findGoodsById(Integer id) {
        return goodsMapper.selectByPrimaryKey(id);
    }


    protected Query query(String sql) {
        return em.createNativeQuery(sql);
    }


    @Autowired
    protected EntityManager em;
    @Autowired
    protected TShopMapper shopMapper;
    @Autowired
    protected TShopApplyMapper shopApplyMapper;
    @Autowired
    protected TUserInfoMapper userInfoMapper;
    @Autowired
    protected TUser2Mapper user2Mapper;
    @Autowired
    protected TWxCashoutApplyMapper wxCashoutApplyMapper;
    @Autowired
    protected TOrderMapper orderMapper;
    @Autowired
    protected TGroupOrderMapper groupOrderMapper;
    @Autowired
    protected TGoodsMapper goodsMapper;
}
